package com.unicom.office.templatefunc;

import com.unicom.office.dataitem.StringDataItem;
import com.unicom.office.runtime.OfficeRuntime;
import com.unicom.office.type.StringTypeItem;
import com.unicom.office.type.TypeItem;
import com.unicom.office.unit.OfficeUnit;
import com.unicom.office.var.StringVarItem;

import java.util.List;

public class JoinFunc extends TemplateFunc {
    public static final JoinFunc INSTANCE = new JoinFunc();

    private JoinFunc(){}

    public Object run(List<Object> params, OfficeRuntime officeRuntime) {
        StringBuffer stringBuffer = new StringBuffer();
        for (Object param : params) {
            StringDataItem str = (StringDataItem) param;
            stringBuffer.append(str.getValue());
        }
        return StringDataItem.create(stringBuffer.toString());
    }

    public void runForMatch(OfficeUnit unit, List<Object> params, OfficeRuntime officeRuntime) {

    }

    public String getName() {
        return "join";
    }

    public TypeItem getType() {
        return StringTypeItem.INSTANCE;
    }
}
